//      Copyright (c) Microsoft Corporation. All rights reserved.
#pragma once
#include "HWIntf.h"
#include "DeviceDiscovery.h"

class CSideShowButtonEventSink;

// implementing the Windows SideShow hardware specific interfaces by calling DPWS SideShow service
class CDPWSSideShow : public CSideShowHW
{
public:
    CDPWSSideShow();
    ~CDPWSSideShow(void);

// Public interfaces 
public:
    HRESULT Initialize(PCWSTR instance, CSideShowButtonEventSink* eventSink);
    void Deinitialize();

    void SetClientID(const WCHAR* pClientID);
    const WCHAR* GetClientID();
    HRESULT GetCaps(ULONG* pWidth, ULONG* pHeight, ULONG* pDepth);
    HRESULT DisplayBitmap(const BYTE* pbBitmapData, DWORD cbBitmapData, DWORD dwRenderFlags);

private:
    WCHAR* m_clientID;
    WCHAR m_ComputerName[MAX_COMPUTERNAME_LENGTH + 1];
    ULONG m_ClientIDSize;
    BOOL m_bInitialized;

    // the following object sequence guarantee 
    // m_DeviceDiscovery will be destruct before m_DeviceProxyProvider
    CDeviceProxyProvider m_DeviceProxyProvider;
    CDeviceDiscovery m_DeviceDiscovery;
};

// implement the button event callback by providing an event sink for DPWS SideShow Service
class ATL_NO_VTABLE CDPWSSideShowEventSink :
    public CComObjectRoot,
    public ISideShowServiceTypeEventNotify
{
public:
    CDPWSSideShowEventSink();
    void Initialize(const wstring& clientID, CSideShowButtonEventSink* pSink);
    virtual ~CDPWSSideShowEventSink();

public:

    virtual HRESULT STDMETHODCALLTYPE SideShowButtonPressedEvent( 
        /* [in] */ SIDE_SHOW_BUTTON_PRESS_TYPE *pButtonValue);

public:
    DECLARE_NOT_AGGREGATABLE(CDPWSSideShowEventSink)

    BEGIN_COM_MAP(CDPWSSideShowEventSink)
        COM_INTERFACE_ENTRY(ISideShowServiceTypeEventNotify)
    END_COM_MAP()
private:
    wstring m_clientID;
    CSideShowButtonEventSink* m_pButtonEventSink;
};

